home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / librw / RWTPtrHashSetIterator.z / RWTPtrHashSetIterator
Encoding:
Text File  |  2002-10-03  |  8.7 KB  |  265 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))                        RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWTPtrHashSetIterator<T,H,EQ> - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include<rw/tphset.h>
  13.  
  14.  
  15.  
  16.               RWTPtrHashSet<T,H,EQ> m;
  17.           RWTPtrHashSet<T,H,EQ> itr(m);
  18.  
  19. PPPPlllleeeeaaaasssseeee NNNNooootttteeee!!!!
  20.      IIIIffff yyyyoooouuuu hhhhaaaavvvveeee tttthhhheeee SSSSttttaaaannnnddddaaaarrrrdddd CCCC++++++++ LLLLiiiibbbbrrrraaaarrrryyyy,,,, uuuusssseeee tttthhhheeee iiiinnnntttteeeerrrrffffaaaacccceeee ddddeeeessssccccrrrriiiibbbbeeeedddd hhhheeeerrrreeee....
  21.      OOOOtttthhhheeeerrrrwwwwiiiisssseeee,,,, uuuusssseeee tttthhhheeee rrrreeeessssttttrrrriiiicccctttteeeedddd iiiinnnntttteeeerrrrffffaaaacccceeee ttttoooo RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhTTTTaaaabbbblllleeeeIIIItttteeeerrrraaaattttoooorrrr
  22.      described in Appendix A.
  23.  
  24.  
  25. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  26.      RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr is supplied with TTTToooooooollllssss....hhhh++++++++ 7.x to provide an
  27.      iterator interface to the Standard Library based collections that has
  28.      backward compatibility with the container iterators provided in TTTToooooooollllssss....hhhh++++++++
  29.      6.x. Iteration over an RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeetttt is pseudorandom and dependent on the
  30.      capacity of the underlying hash table and the hash function being used.
  31.      The current item referenced by this iterator is undefined after
  32.      construction or after a call to rrrreeeesssseeeetttt(((()))).  The iterator becomes valid
  33.      after being advanced with either a pre-increment or an ooooppppeeeerrrraaaattttoooorrrr(((()))).  For
  34.      both ooooppppeeeerrrraaaattttoooorrrr++++++++ and ooooppppeeeerrrraaaattttoooorrrr(((()))), iterating past the last element will
  35.      return a value equivalent to boolean ffffaaaallllsssseeee.  Continued increments will
  36.      return a value equivalent to ffffaaaallllsssseeee until rrrreeeesssseeeetttt(((()))) is called.
  37.  
  38. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  39.      None
  40.  
  41. EEEExxxxaaaammmmpppplllleeeessss
  42.               #include<rw/tphset.h>
  43.  
  44.  
  45.  
  46.               #include<iostream.h>
  47.           #include<rw/cstring.h>
  48.           struct silly_h{
  49.              unsigned long operator()(RWCString x) const
  50.                { return x.length() * (long)x(0); }
  51.           };
  52.  
  53.  
  54.               int main(){
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))                        RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.                  RWTPtrHashSet <RWCString,silly_h,equal_to<RWCString> > age;
  75.  
  76.  
  77.  
  78.                  RWTPtrHashSetIterator
  79.  
  80.  
  81.  
  82.                    <RWCString,silly_h,equal_to<RWCString> > itr(age);
  83.  
  84.  
  85.  
  86.                  age.insert(new RWCString("John"));
  87.  
  88.  
  89.  
  90.                  age.insert(new RWCString("Steve"));
  91.              age.insert(new RWCString("Mark"));
  92.  
  93.  
  94.               //Duplicate insertion is rejected
  95.  
  96.  
  97.  
  98.                  age.insert(new RWCString("Steve"));
  99.  
  100.  
  101.  
  102.                  for(;++itr;) cout << *itr.key() << endl;
  103.              return 0;
  104.  
  105.  
  106.  
  107.               }
  108.  
  109.  
  110.  
  111.               Program Output (not necessarily in this order)
  112.  
  113.  
  114.  
  115.               John
  116.           Mark
  117.           Steve
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))                        RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  141.               RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr<<<<TTTT,,,,HHHH,,,,EEEEQQQQ>>>>(RWTPtrHashSet<T,H,EQ>&h);
  142.  
  143.  
  144.      Creates an iterator for the hashed set hhhh.  The iterator begins in an
  145.      undefined state and must be advanced before the first element will be
  146.      accessible.
  147.  
  148. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss
  149.               T*
  150.           ooooppppeeeerrrraaaattttoooorrrr(((())))();
  151.  
  152.  
  153.      Advances self to the next element, dereferences the resulting iterator
  154.      and returns its value.  If the iterator has advanced past the last item
  155.      in the container,  the element returned will be a nnnniiiillll pointer equivalent
  156.      to boolean ffffaaaallllsssseeee.
  157.  
  158.               RWBoolean
  159.           ooooppppeeeerrrraaaattttoooorrrr++++++++();
  160.  
  161.  
  162.      Advances self to the next element.  If the iterator has been reset or
  163.      just created self will now reference the first element.  If, before
  164.      iteration, self referenced the last association in the multi-map, self
  165.      will now point to an undefined value and a value equivalent to ffffaaaallllsssseeee will
  166.      be returned.  Otherwise, a value equivalent to ttttrrrruuuueeee is returned. Note: no
  167.      post-increment operator is provided.
  168.  
  169. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  170.               RWTPtrHashSet<T,H,EQ>*
  171.           ccccoooonnnnttttaaaaiiiinnnneeeerrrr(((()))) const;
  172.  
  173.  
  174.      Returns a pointer to the collection being iterated over.
  175.  
  176.               T*
  177.           kkkkeeeeyyyy() const;
  178.  
  179.  
  180.      Returns the element referenced by sssseeeellllffff. Undefined if self is not
  181.      referencing a value within the set.
  182.  
  183.               void
  184.           rrrreeeesssseeeetttt();
  185.           void
  186.           rrrreeeesssseeeetttt(RWTPtrHashSet<T,H,EQ>& h);
  187.  
  188.  
  189.      Resets the iterator so that after being advanced it will reference the
  190.      first element of the collection.  Using rrrreeeesssseeeetttt(((()))) with no argument will
  191.      reset the iterator on the current container.  Supplying a RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeetttt
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))                        RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.      to rrrreeeesssseeeetttt(((()))) will reset the iterator on that container.
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.